<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('客户名称') }}</td>
        <td>{{ form.customerName }}</td>
        <td class="tit">{{ $t('项目收款') }}</td>
        <td>{{ form.projectCollectionName }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('收款金额(元)') }}</td>
        <td>
          {{ moneyFormat(form.collectedAmount) }}
        </td>
        <td class="tit">{{ $t('纳税人识别号') }}</td>
        <td>{{ form.taxpayerNumber }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('开票公司') }}</td>
        <td>
          {{ invoiceCompanyFormat(form.invoiceCompany) }}
        </td>
        <td class="tit">{{ $t('发票类型') }}</td>
        <td>{{ invoiceFormat(form.invoiceType) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('开户行及账号') }}</td>
        <td>
          {{ form.bankAccount }}
        </td>
        <td class="tit">{{ $t('地址及电话') }}</td>
        <td>{{ form.addressPhone }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('开票内容') }}</td>
        <td>
          {{ form.invoiceContent }}
        </td>
        <td class="tit">{{ $t('邮寄地址') }}</td>
        <td>{{ form.mailingAddress }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('开票人') }}</td>
        <td>
          <UserSelect
            v-model="form.drawer"
          />
        </td>
        <td class="tit">{{ $t('开票时间') }}</td>
        <td>{{ parseTime(form.invoiceTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('备注') }}</td>
        <td colspan="3">{{ form.remark }}</td>
      </tr>
    </table>

    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="anxin_invoice" :btn-show="!otherBtnHide" />

  </div>

</template>

<script>
import { getAnxinInvoiceApply } from '@/api/anxin/invoice/anxinInvoiceApply'
export default {
  components: {},
  data() {
    return {
      // 开票类型
      invoiceTypeOptions: [],
      // 开票公司
      invoiceCompanyOptions: [],
      form: {},
      otherBtnHide: false,
      buttonShow: true
    }
  },
  created() {
    this.getDicts('invoice_type').then((response) => {
      this.invoiceTypeOptions = response.data
    })
    this.getDicts('invoice_company').then((response) => {
      this.invoiceCompanyOptions = response.data
    })
    this.$bus.$emit('async_done')
  },
  methods: {
    invoiceFormat(row) {
      return this.selectDictLabel(this.invoiceTypeOptions, row)
    },
    invoiceCompanyFormat(row) {
      return this.selectDictLabel(this.invoiceCompanyOptions, row)
    },
    // 初始化数据
    init(data) {
      if (data != null && data.id !== undefined) {
        getAnxinInvoiceApply(data.id).then((response) => {
          this.form = response.data
          if (data.isCopy) {
            this.form.id = undefined
          }
        })
      }
    }
  }
}
</script>
